<?php require_once('../conn/DBconnect.php'); ?>
<?php
	
	$emailErr = "Invalid email";
	
	$params[0] = "MIGRATE_RECORD";
	$params[1] = "0";
 	$params[2] = $_POST["r_code"];
 	$params[3] = $_POST["r_firstName"];
 	$params[4] = $_POST["r_lastName"];
 	$params[5] = $_POST["r_middle_ini"];
 	$params[6] = $_POST["r_gender"];
 	$params[7] = $_POST["r_birthdate"];
 	$params[8] = $_POST["r_email"];
 	$params[9] = $_POST["r_mobile"];
 	$params[10] = $_POST["r_nationality"];
 	$params[11] = $_POST["r_country"];
 	$params[12] = $_POST["r_address1"];
 	$params[13] = $_POST["r_address2"];
 	$params[14] = $_POST["r_delivery_add"];
 	$params[15] = $_POST["r_contact_name"];
 	$params[16] = $_POST["r_contact_phone"];
 	$params[17] = $_POST["r_size"];
 	$params[18] = $_POST["r_color"];
 	$params[19] = $_POST["r_reg_outlet"];
 	$params[20] = $_POST["r_reg_cat"];
 	$params[21] = $_POST["r_promo_no"];
 	$params[22] = $_POST["r_race_code"];
 	$params[23] = $_POST["r_bib"];
 	$params[24] = "0";
 	
 	
 	if (filter_var($params[6], FILTER_VALIDATE_EMAIL)) {
    	$insertPROC = "CALL SP_REGISTRATION('" . implode("', '", $params) . "');";
	 	$result = mysqli_query($mysqlLink, $insertPROC);
	 	
	 	$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
	 	
	 	mysqli_free_result($result);
	
		mysqli_close($mysqlLink);
	
	 	echo $row["err_code"];
	}
	else
		echo $emailErr;
?>